package ca.uvic.group2.beans;

import java.util.*;
//import java.io.Serializable;

public class UserInfoBean
{

	private String userName;
	private float balance;
	private float reserveBalance;
	private float triggerReserveBalance;
	private Hashtable stocks = new Hashtable();
	private List pendingBuys = new LinkedList(); // Temp, Not stored in DB
	private List pendingSells = new LinkedList(); // Temp, Not stored in DB
	private Hashtable buyTriggers = new Hashtable();
	private Hashtable sellTriggers = new Hashtable();


	public UserInfoBean(UserInfoBean src) 
	{
		this(src.userName, src.balance, src.reserveBalance, src.triggerReserveBalance, src.stocks);
		setBuyTriggers(src.buyTriggers);
		setSellTriggers(src.sellTriggers);
	}

	public UserInfoBean(String userName, float balance, float reserveBalance, float triggerReserveBalance, Hashtable stocks) 
	{
		setUserName(userName);
		setBalance(balance);
		setTriggerReserveBalance(triggerReserveBalance);
		setReserveBalance(reserveBalance);
		setStocks(stocks);
	}

	/*
	 *  GETTER/SETTER
	 */
	public String getUserName()
	{
		return this.userName;
	}
	public void setUserName(String userName)
	{
		this.userName = userName;
	}

	public float getBalance() 
	{
		return this.balance;
	}
	public void setBalance(float balance) 
	{
		this.balance = balance;
	}
    
	public float getReserveBalance()
	{
		return this.reserveBalance;
	}
	public void setReserveBalance(float reserveBalance)
	{
		this.reserveBalance = reserveBalance;
	}
    
	public float getTriggerReserveBalance()
	{
		return this.triggerReserveBalance;
	}
	public void setTriggerReserveBalance(float triggerReserveBalance)
	{
		this.triggerReserveBalance = triggerReserveBalance;
	}
    
	public Hashtable getStocks() 
	{
		return this.stocks;
	}
    
	public Hashtable getBuyTriggers()
	{
		return this.buyTriggers;
	}
	public void setBuyTriggers(Hashtable buyTriggers)
	{
		this.buyTriggers.putAll(buyTriggers);
	}
    
	public Hashtable getSellTriggers()
	{
		return this.sellTriggers;
	}
	public void setSellTriggers(Hashtable sellTriggers)
	{
		this.sellTriggers.putAll(sellTriggers);
	}
    
	public List getPendingBuys()
	{
		return this.pendingBuys;
	}
	public void setPendingBuys(List pendingBuys)
	{
		this.pendingBuys = pendingBuys;
	}
    
	public List getPendingSells() 
	{
		return this.pendingSells;
	}
	public void setPendingSells(List pendingSells)
	{
		this.pendingSells = pendingSells;
	}
    
	public void setStocks(Hashtable stocks) 
	{
//		this.stocks.clear();
//		if (stocks != null) 
//		{
//			Iterator i = stocks.values().iterator();
//			while (i.hasNext()) 
//			{
//				StockRecordBean r = (StockRecordBean)i.next();
//				this.stocks.put(r.stock, r);
//			}
//		}
	}

	public void setStocks(StockRecordBean[] stocks) 
	{
//		this.stocks.clear();
//		if (stocks != null) 
//		{
//			for (int i = 0; i < stocks.length; ++i) 
//			{
//				this.stocks.put(stocks[i].stock, stocks[i]);
//			}
//		}
	}
}
